<%--
  Created by IntelliJ IDEA.
  User: Mr.G
  Date: 2018/12/29
  Time: 15:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <%@ include file="/WEB-INF/jsp/common.jsp"%>
</head>
<body>
<h2>就诊查询</h2>
<hr>
<form class="layui-form" action="">
    <div class="layui-input-inline">
        <label class="layui-form-label">病历号：</label>
        <div class="layui-input-inline">
            <input type="text" id="medicalRecordNo" name="title" placeholder="病历号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-input-inline">
        <label class="layui-form-label">患者姓名：</label>
        <div class="layui-input-inline">
            <input type="text" id="ReserveName" name="title" placeholder="患者姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-input-inline">
        <button class="layui-btn" type="submit" onclick="reloadData();return false">查询</button>
    </div>

    <table class="layui-table" lay-filter="ReserveTable"lay-data="{ url:'${path}/jiuzhen/getlist', page:true, id:'ReserveTable',toolbar:'#toolbarDemo'}">
        <thead>
            <th lay-data="{checkbox:true}"></th>
            <th lay-data="{field:'reserveId'}">编号</th>
            <th lay-data="{field:'medicalRecordNo'}">病例编号</th>
            <th lay-data="{field:'reserveName'}">患者姓名</th>
            <th lay-data="{field:'reserveSex'}">性别</th>
            <th lay-data="{field:'reserveshenfen'}">身份证</th>
            <th lay-data="{field:'reserveMobile'}">手机号</th>
            <th lay-data="{field:'reserveStartDate'}">就诊登记时间</th>
            <th lay-data="{field:'memo'}">备注</th>
            <th lay-data="{toolbar:'#barDemo'}">操作</th>
        </thead>
    </table>
</form>

<script>
    function reloadData(){
        layui.table.reload("ReserveTable",{
            page:{
                curr:1
            },
            where:{
                reserveName:$("#ReserveName").val(),
                medicalRecordNo:$("#medicalRecordNo").val()
            }
        })
    }

    layui.use(['table','laydate','form'],function () {
        var table = layui.table;

        table.on('toolbar(ReserveTable)', function(obj){
            var e = obj.event;
            if (e == "delete"){
                /*批量删除*/
                var checkStatus = table.checkStatus('ReserveTable');

                if (checkStatus.data.length == 0){
                    layer.msg("请选择要删除的行",function () {})
                    return;
                }

                layer.confirm('确认删除辣么多的数据吗?', {icon: 3, title:'友情提示'}, function(index){
                    var parem = "";

                    for (let r of checkStatus.data) {
                        parem += "ids="+r.reserveId+"&";
                    }

                    $.get("${path}/yuyuedengji/batchDelete",parem,function (data) {
                        layer.msg("删除成功！")
                        layui.table.reload("ReserveTable")
                    })

                })
            }else if (e=="add"){
                /*
                *
                * 添加预约弹出层
                * */

                $.get("${path}/jiuzhen/jiuzhenfrom",function (str) {
                    var index = layer.open({
                        type: 1,
                        title:"就诊登记",
                        content: str,
                        area: ['100%','100%'],
                        btn:['确定','取消'],
                        maxmin: true,
                        yes:function (index) {
                            var membershipCardNo = $("#membershipCardNo").val();
                            if (membershipCardNo == null || membershipCardNo == ''){
                                layer.tips('请输入会员账号', '#membershipCardNo',{
                                    tips: 3
                                });
                                return;
                            }


                            var parems = $("#Reservleform").serialize();
                            console.log(parems)
                            $.post("${path}/jiuzhen/addjiuzhen",parems,function (data) {
                                layer.close(index);
                                table.reload('ReserveTable');
                                layer.msg("就诊登记成功！")
                            })
                        }
                    });
                    // layer.full(index);
                })
            }
        })
    })

</script>

<script type="text/html" id="barDemo">
    <shiro:hasPermission name="dengji:upd">
        <a href="javascript:void(0)" lay-event="upd"><i class="layui-icon layui-icon-edit"></i></a>
    </shiro:hasPermission>
    <shiro:hasPermission name="dengji:del">
        <a href="javascript:void(0)" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
    </shiro:hasPermission>
</script>
<script type="text/html" id="toolbarDemo">
    <shiro:hasPermission name="dengji:del">
        <button class="layui-btn " type="button" lay-event="delete">批量删除</button>
    </shiro:hasPermission>
    <shiro:hasPermission name="dengji:add">
        <button class="layui-btn " type="button" lay-event="add">就诊登记</button>
    </shiro:hasPermission>
</script>
</body>
</html>
